import { get_list, delete_one } from "@/apis/MessageApi"
import { ElMessage } from "element-plus";


import { defineStore } from "pinia";
const MessageStore = defineStore('message', () => {

    const get_lists = async (id: number) => {
        const result: any = await get_list(id)
        if (result.code === 200) {
            console.log(result, 'sssss')
            return {
                data: result.data,
                count: result.count
            }

        }
    }
    const one_delete = async (id: string) => {
        const result: any = await delete_one(id)
        console.log(result, '...')
        if (result.code === 200) {
            ElMessage({
                type: "success",
                message: '删除成功'

            })
        } else {

            ElMessage({
                type: "error",
                message: '删除失败'

            })

        }
    }

    return {
        get_lists,
        one_delete
    }
})

export default MessageStore